from django.shortcuts import render,HttpResponse
from rest_framework.views import APIView
from rest_framework.response import Response
from django.http import JsonResponse

# Create your views here.
def home(request):
    return HttpResponse("Hello, world. You're at the polls index.| home Page!!")

class TestView(APIView):
    def get(self, request):
        return HttpResponse({"message":"访问首页200成功了。"})
    

def getMiddlewareList(request):
    page_num = request.GET.get('pageNum')  # 获取pageNum
    page_size = request.GET.get('pageSize')  # 获取pageSize
    name = request.GET.get('name')  # 获取name

    print(f"pageNum: {page_num}")
    print(f"pageSize: {page_size}")
    print(f"name: {name}")
    # 根据上面的值判断如何返回数据
    data = {
        "pageNum": 1,
        "pageSize": 10,
        "totalPage": 10,
        "total": 56,
        "list":[
            {"id":1,"name":"nginx","version":"1.18.0"},
            {"id":2,"name":"tomcat","version":"9.0.41"},
            {"id":3,"name":"IIS","version":"10.0"},
        ]
    }
        

    return JsonResponse({"code":200,"info":"获取中间件列表成功","data":data})